﻿using System;
using SCG = System.Collections.Generic;

using Nemerle.Assertions;
using Nemerle.Utility;

using GASS.OpenCL;
using GASS.OpenCL.OpenCLDriver;

namespace Nemerle.OpenCL {

    public sealed class Image2D : Image {

        public this(context : Context, create_info : ImageCreateInfo2D, flags = CLMemFlags.ReadWrite) {
            this(context, create_info, null, flags)
        }

        public this(context : Context, [NotNull] create_info : ImageCreateInfo2D, host_ptr : object, flags = CLMemFlags.ReadWrite) {
            base(context, create_info, host_ptr, flags);
            Initialize();
        }

        protected override CreateHandle(host_ptr : IntPtr, format : ref CLImageFormat, create_info : ImageCreateInfo) : CLMem {
            def create_info = create_info :> ImageCreateInfo2D;
            CheckErrorTail(clCreateImage2D(Context.Id,
                Flags,
                ref format,
                create_info.Width,
                create_info.Height,
                create_info.RowPitch,
                host_ptr))
        }

    }


    [Record]
    public class ImageCreateInfo2D : ImageCreateInfo {

        public this() { };

        [Accessor(flags = WantSetter)] mutable width : int;
        [Accessor(flags = WantSetter)] mutable height : int;
        [Accessor(flags = WantSetter)] mutable row_pitch : int;

    }

}